<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>登录页面马尔代夫后台管理系统模板</title>
<link rel="stylesheet" href="css/login.css" type="text/css" />
<link type="text/css" rel="stylesheet" href="font/font-awesome.min.css"/>
<script src="http://cdn.static.runoob.com/libs/jquery/1.10.2/jquery.min.js">
</script>
<script type="text/javascript">
var xmlrequest;
function createXMLHttpRequest(){
      if(window.XMLHttpRequest){
       xmlrequest=new XMLHttpRequest();
      }
      else if(window.ActiveXObject){
         try{
           xmlrequest=new ActiveXObject("Msxm12.XMLHTTP");
         }
         catch(e){
            try{
             xmlrequest=new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch(e){}
         } 
      }
}

function login(){   
 createXMLHttpRequest();
  var user_userName = document.getElementById("user_userName").value;
  var user_userPass = document.getElementById("user_userPass").value;
 var radio=document.getElementsByName("power");
 var selectvalue=null;   //  selectvalue为radio中选中的值
for(var i=0;i<radio.length;i++){
       if(radio[i].checked==true) {
                selectvalue=radio[i].value;
                break;
      }
}
var user1 =selectvalue; 

  if(user_userName==""||user_userPass==""){
   alert("请输入用户名和密码!");
   return false;
  }
  
  if(user1=="管理员"){//if**************************
  var url = "loginServlet?user_userName="+user_userName+"&user_userPass="+user_userPass;//+"&user1="+user1

  xmlrequest.open("POST",url,true);
 /*  alert(111); */
  xmlrequest.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
   xmlrequest.onreadystatechange = function(){
  if(xmlrequest.readyState == 4){
   if(xmlrequest.status==200){
      var msg = xmlrequest.responseText;   
        if(msg=="ff"){
        alert('用户名或密码错误!');
        user_userName="";
        user_userPass="";
        return false;
                      } 
      else{       
        window.location.href="index.jsp";
           } 
        }
  }
   };
  
   xmlrequest.send("user_userName="+user_userName+"&user_userPass="+user_userPass);//+"&user1"+user1
   
  }//if结尾*******************************
  
  else{
	  var url = "ClientLoginServlet?user_userName="+user_userName+"&user_userPass="+user_userPass;
	  xmlrequest.open("POST",url,true);
	 /*  alert(111); */
	  xmlrequest.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	   xmlrequest.onreadystatechange = function(){
	  if(xmlrequest.readyState == 4){
	   if(xmlrequest.status==200){
	      var msg = xmlrequest.responseText;   
	        if(msg=="ff"){
	        alert('用户名或密码错误!');
	        user_userName="";
	        user_userPass="";
	        return false;
	                      } 
	      else{       
	        window.location.href="BookIn.jsp";
	           } 
	        }
	  }
	   };
	  
	   xmlrequest.send("user_userName="+user_userName+"&user_userPass="+user_userPass);//+"&user1"+user1
	   
	  }//else结尾*************
 }
</script>
</head>

<body class="loginpage">
	<div class="loginbox">
    	<div class="loginboxinner">
        	
            <div class="logo">
            	<h1 class="logo">马尔代夫大酒店.<span>管理系统</span></h1>
				<span class="slogan">后台管理系统</span>
            </div>
       <div class="username">
                	<div class="usernameinner">
                    	<input type="text" name="user_userName" id="user_userName" placeholder="用户名"/>
                    </div>
                </div>
    
                <div class="password">
                	<div class="passwordinner">
                    	<input type="password" name="user_userPass" id="user_userPass" placeholder="密码" />
                    </div>
                </div>
                <div style="float:right; text-align:right">
                	<div>
                	<input name="power" type="radio" value="用户" checked="checked"/>用户 
                    <input name="power"  type="radio" value="管理员" />管理员
                     </div>
                </div>
                	
               <button id="dl" onclick="login()">登录</button>
                                                                  
                       <div style="float:right; text-align:right;text-decoration:underline" >   
                       		  如果您还没有注册，请单击<a href="register.jsp">这里</a>注册！ 
                       </div>                                           
         
        </div>
    </div>
			
<object id="mPlayer1" width=300 height=300 classid="CLSID:6BF52A52-394A-11D3-B153-00C04F79FAA6" hidden="true">
<param name="URL" value="d:/海浪声.mp3"/>
        <param name="rate" value="1"/>
        <param name="balance" value="0"/>
        <param name="currentPosition" value="0"/>
        <param name="defaultFrame" value/>
        <param name="playCount" value="100"/>
        <param name="autoStart" value="1"/>
        <param name="currentMarker" value="0"/>
        <param name="invokeURLs" value="1"/>
        <param name="baseURL" value/>
        <param name="volume" value="100"/>
        <param name="mute" value="0"/>
        <param name="uiMode" value="full"/>
        <param name="stretchToFit" value="0"/>
        <param name="windowlessVideo" value="0"/>
        <param name="enabled" value="1"/>
        <param name="enableContextMenu" value="1"/>
        <param name="fullScreen" value="0"/>
        <param name="SAMIStyle" value/>
        <param name="SAMILang" value/>
        <param name="SAMIFilename" value/>
        <param name="captioningID" value/>
        <param name="enableErrorDialogs" value="0"/>
        <param name="_cx" value="7779"/>
        <param name="_cy" value="1693"/>
      </object>
</body>
</html>
